<?php 
if( have_posts() ) : 
	while( have_posts() ) : the_post();
?>
	<article class="entry">
		<?php if(has_post_thumbnail()) : ?>
			<a class="thumbnail" href="<?php the_permalink(); ?>">
				<?php the_post_thumbnail(); ?>
			</a>
		<?php endif; ?>

		<h1><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title_attribute(); ?></a></h1>
		<p class="excerpt">
			<?php
				echo mb_strimwidth(wp_strip_all_tags($post->post_content, true), 0, 200, '...' );
			?>
		</p>
		<footer class="post-meta">
			<span class="category dashicons dashicons-category"><?php the_category( ' ', '' ); ?></span>
			<span class="likes dashicons dashicons-heart"><?php bzg_post_meta('likes'); ?></span>
			<span class="views dashicons dashicons-visibility"><?php bzg_post_meta('views'); ?></span>
			<?php if(comments_open() && 'open' == get_option('default_comment_status')) : ?>
				<span class="comments dashicons dashicons-admin-comments"><?php comments_popup_link( '0', '1', '%' ); ?></span>
			<?php endif; ?>
		</footer>
	</article>

<?php
	endwhile;
	
	$pagination = paginate_links(array(
		'mid_size' => 1,
		'type' => 'array',
		'prev_text' => '<span aria-hidden="true">&laquo;</span>',
		'next_text' => '<span aria-hidden="true">&raquo;</span>',
	));
	if($pagination) {
		echo '<nav id="pagination" class="entry" aria-label="Page navigation example"><ul class="pagination">';
		foreach($pagination as $page) {
			$liclass = $liaria = '';
			if(strpos($page, 'current') !== false) {
				$liclass = ' active';
				$liaria = ' aria-current="page"';
			}
			$page = str_replace('page-numbers', 'page-link', $page);
			echo '<li class="page-item' . $liclass . '"' . $liaria . '>' . $page . '</li>';
		}
		echo '</ul></nav>';
	}

	wp_reset_query();

endif;
?>
